home *** CD-ROM | disk | FTP | other *** search
Text File | 1996-01-29 | 3.0 KB | 89 lines | [TEXT/IGR0] |
- | XYZtoMatrix
- | This procedure file contains two macros to convert X, Y, and Z values
- | into a 2-D matrix of Z values:
- | XYZtoMatrix, which converts the entire XY domain into a matrix
- | and XYZtoMatrixRange, which converts a given XY domain into a matrix.
-
- // Converts three waves containing X, Y, and Z values into
- // a matrix of Z values that spans the min and max X and Y.
- Macro XYZtoMatrix(wx,mat,wy,rows,wz,cols,mktbl,mkimg)
- String wx,wy,wz,mat="matrix"
- Variable rows=20,cols=20,mktbl=2,mkimg=2
- Prompt wx,"X Wave",popup,WaveList("*",";","")
- Prompt mat,"Output matrix name"
- Prompt wy,"Y Wave",popup,WaveList("*",";","")
- Prompt rows,"number of rows for matrix"
- Prompt wz,"Z Wave",popup,WaveList("*",";","")
- Prompt cols,"number of columns for matrix"
- Prompt mktbl,"Put matrix in new table?",popup,"Yes;No"
- Prompt mkimg,"Display matrix as image?",popup,"Yes;No"
-
- Silent 1;PauseUpdate
- // Make matrix that spans X and Y
- Make/O/N=(rows,cols) $mat
- WaveStats/Q $wx
- SetScale/I x, V_min, V_max, "",$mat
- WaveStats/Q $wy
- SetScale/I y, V_min, V_max, "",$mat
- // Make a temporary contour plot
- // so we can use ContourZ to interpolate from X,Y,Z into MatrixXY
- Display/W=(0,30,200,80) // teeny window
- DoWindow/C WM_XYZtoMatrix
- AppendXYZContour $wz vs {$wx ,$wy};ModifyContour $wz autoLevels={*,*,0},update=1,labels=0
- ModifyGraph axThick=0,nolabel=2;Textbox/A=LC/F=0 "Computing "+mat;DoUpdate
- $mat= ContourZ("","",0,x,y)
- DoWindow/K WM_XYZtoMatrix
- Preferences 1
- if( mktbl == 1)
- Edit $mat
- endif
- if( mkimg == 1)
- Display;AppendImage $mat
- endif
- End
-
- // Converts three waves containing X, Y, and Z values into
- // a matrix of Z values that spans the given (or auto) X and Y range
- Macro XYZtoMatrixRange(wx,mat,wy,rows,wz,cols,xmin,xmax,ymin,ymax)
- String wx,wy,wz,mat="matrix"
- Variable rows=20,cols=20,xmin=NaN,xmax=NaN,ymin=NaN,ymax=NaN
- Prompt wx,"X Wave",popup,WaveList("*",";","")
- Prompt mat,"Output matrix name"
- Prompt wy,"Y Wave",popup,WaveList("*",";","")
- Prompt rows,"number of rows for matrix"
- Prompt wz,"Z Wave",popup,WaveList("*",";","")
- Prompt cols,"number of columns for matrix"
- Prompt xmin,"matrix min X, or NaN for auto min X"
- Prompt xmax,"matrix max X, or NaN for auto max X"
- Prompt ymin,"matrix min Y, or NaN for auto min Y"
- Prompt ymax,"matrix max Y, or NaN for auto max Y"
-
- Silent 1;PauseUpdate
- // Make matrix that spans X and Y
- Make/O/N=(rows,cols) $mat
- WaveStats/Q $wx
- if(numtype(xmin)==0)
- V_min=xmin
- endif
- if(numtype(xmax)==0)
- V_max=xmax
- endif
- SetScale/I x, V_min, V_max, "",$mat
- WaveStats/Q $wy
- if(numtype(ymin)==0)
- V_min=ymin
- endif
- if(numtype(ymax)==0)
- V_max=ymax
- endif
- SetScale/I y, V_min, V_max, "",$mat
- // Make a temporary contour plot
- // so we can use ContourZ to interpolate from X,Y,Z into MatrixXY
- Display/W=(0,30,200,80) // teeny window
- DoWindow/C WM_XYZtoMatrix
- AppendXYZContour $wz vs {$wx ,$wy};ModifyContour $wz autoLevels={*,*,0},update=1,labels=0
- ModifyGraph axThick=0,nolabel=2;Textbox/A=LC/F=0 "Computing "+mat;DoUpdate
- $mat= ContourZ("","",0,x,y)
- DoWindow/K WM_XYZtoMatrix
- End
-